/**
 * Project  : monkey
 * Author   : Wu Tian Qiang
 * Date     : 2016/10/14 18:39:22
 */
Ext.define('Monkey.view.organization.OrganizationWindow', {
    extend: 'Ext.window.Window',

    requires: [
        'Monkey.view.organization.OrganizationController',
        'Monkey.view.organization.OrganizationModel',
        'Ext.ux.TreePicker'
    ],

    controller: 'ctrl-organization',
    viewModel: 'vm-organization',
    closable: true,
    resizable: false,
    constrain: true,
    constrainHeader: true,
    modal: true,
    frameHeader: false,
    frame: true,
    maximizable: false,
    layout: 'fit',
    width: 360,
    height: 350,
    initComponent: function () {
        var form = {
            xtype: 'form',
            border: false,
            buttonAlign: 'center',
            reference: 'form',
            layout: 'form',
            bodyStyle: 'padding:15px 5px 0 5px',
            defaults: {
                labelWidth: 80,
                labelAlign: 'right'
            },
            defaultType: 'textfield',
            buttons: [{
                //formBind: true,
                text: '确定',
                iconCls: 'accept',
                handler: 'ok'
            }, {
                text: '取消',
                iconCls: 'delete',
                handler: 'winCancel'
            }]
        };

        form.items = [{
            editable: false,
            xtype: 'orgtreepicker',
            allowBlank: false,
            fieldLabel: '<span style="color: red;">*</span>上级组织',
            name: 'parentId',
            bind: '{parentId}'
        }, {
            bind: '{name}',
            name: 'name',
            allowBlank: false,
            maxLength: '15',
            fieldLabel: '<span style="color: red;">*</span>组织名称'
        }, {
            bind: '{type}',
            name: 'type',
            xtype: 'combobox',
            editable: false,
            allowBlank: false,
            fieldLabel: '<span style="color: red;">*</span>类型',
            displayField: 'label',
            valueField: 'value',
            store: Monkey.Config.organizationType
        }, {
            bind: '{icon}',
            name: 'icon',
            maxLength: '50',
            allowBlank: false,
            fieldLabel: '<span style="color: red;">*</span>图标'
        }, {
            bind: '{expand}',
            name: 'expand',
            xtype: 'combobox',
            editable: false,
            allowBlank: false,
            fieldLabel: '默认展开',
            displayField: 'label',
            valueField: 'value',
            store: Monkey.Config.booleanStore
        }, {
            bind: '{status}',
            name: 'status',
            xtype: 'combobox',
            allowBlank: false,
            editable: false,
            fieldLabel: '状态',
            displayField: 'label',
            valueField: 'value',
            store: Monkey.Config.statusStore
        }, {
            bind: '{weight}',
            name: 'weight',
            xtype: 'numberfield',
            allowBlank: false,
            fieldLabel: '<span style="color: red;">*</span>排序'
        }, {
            bind: '{id}',
            name: 'id',
            xtype: 'hidden'
        }];

        this.items = [form];
        this.callParent();
    }
});